import { defineStore } from "pinia";
import type { UserInfo } from "../api/types";

export const useAuthStore =  defineStore('',{
    state:()=>{
        return {
            isAuthenticated:false,
            decode:{} as unknown
        }
    },
    getters:{
        getAuthenticated:(state)=>state.isAuthenticated,
        getUser:(state)=>state.decode,
    },
    actions:{
        setAuth(isAuth:boolean){
            if(isAuth){
                this.isAuthenticated=isAuth
            }else{
                this.isAuthenticated=false
            }
        },
        setUser(decode:unknown){
        
        if(decode){
            this.decode=decode;
        }else{
            this.decode={} as unknown
        }
    },
}
})